package com.yywz.io;

import java.io.*;

public class IOTest {

	public static void main(String[] args) throws Exception {
		//IOTest test = new IOTest();
		// test.testPrintWriter();
		// test.testInputStreamReader();
		//test.testBufferedReader();
		testFileWriter();
	}

	public void testBufferedReader() throws Exception {
		BufferedReader br = new BufferedReader(new FileReader("test.txt"));
		String line;
		while ((line = br.readLine()) != null) {
			System.out.println(line);
		}
	}

	public void testPrintWriter() throws Exception {
		PrintWriter out = new PrintWriter(new FileWriter("test.txt"));
		out.print("hello");
		out.print(" nick!");
		out.flush();
	}

	public void testInputStreamReader() throws Exception {
		InputStreamReader in = new InputStreamReader(System.in);
		int result;
		while ((result = in.read()) != -1) {
			System.out.println(result);
		}
	}
	
	public static void testFileWriter() throws IOException{
		File file = new File("process.xml");
		FileWriter fileWriter = new FileWriter(file);
		
		fileWriter.write("System");
		
		fileWriter.close();
	}
	
}
